import axios from 'axios';
// axios.defaults.withCredentials=true;

let windowhost = window.location.host;

const setHost = (windowhost) => {
    switch(windowhost){
        case 'pay.dfjmdigital.com': return 'http://pay.dfjmdigital.com';
        default: return 'http://10.10.10.140:8088';
        // default: return 'http://pay.dfjmdigital.com';
    }
}
export const host = setHost(windowhost);
let base = host + '/cam/public/index.php';

/**
 * 用户管理
 */
export const submit = params => { return axios.post(`${base}/admin/useradmin/submit`, params).then(res => res.data); }; 
export const logout = params => { return axios.get(`${base}/admin/useradmin/logout`, {params: params}).then(res => res.data); };

export const userChangepw = params => { return axios.get(`${base}/admin/useradmin/changepw`, {params: params}).then(res => res.data); };
export const userResetpw = params => { return axios.get(`${base}/admin/useradmin/resetpw`, {params: params}).then(res => res.data); };
export const userAdd = params => { return axios.get(`${base}/admin/useradmin/add`, {params: params}).then(res => res.data); };
export const userEdit = params => { return axios.get(`${base}/admin/useradmin/edit`, {params: params}).then(res => res.data); };
export const userDel = params => { return axios.get(`${base}/admin/useradmin/del`, {params: params}).then(res => res.data); };
export const userlist = params => { return axios.get(`${base}/admin/useradmin/userlist`, {params: params}).then(res => res.data); };

/**
 * 用户权限接口
 */
export const rightGetall = params => { return axios.get(`${base}/admin/rightadmin/getall`, {params: params}).then(res => res.data); };
export const rightGetlist = params => { return axios.get(`${base}/admin/rightadmin/getlist`, {params: params}).then(res => res.data); };
export const rightAdd = params => { return axios.get(`${base}/admin/rightadmin/add`, {params: params}).then(res => res.data); };
export const rightDel = params => { return axios.get(`${base}/admin/rightadmin/del`, {params: params}).then(res => res.data); };

/**
 * 用户录入审核接口
 */
export const uuaGetchecklist = params => { return axios.get(`${base}/admin/userunauthadmin/getchecklist`, {params: params}).then(res => res.data); };
export const uuaCheck = params => { return axios.get(`${base}/admin/userunauthadmin/check`, {params: params}).then(res => res.data); };
export const uuaGetcheckdetail = params => { return axios.get(`${base}/admin/userunauthadmin/getcheckdetail`, {params: params}).then(res => res.data); };

/**
 * 盗版录入接口
 */
export const unauthCheckurl = params => { return axios.get(`${base}/admin/unauthadmin/checkurl`, {params: params}).then(res => res.data); };
export const unauthAdd = params => { return axios.get(`${base}/admin/unauthadmin/add`, {params: params}).then(res => res.data); };
export const unauthEdit = params => { return axios.get(`${base}/admin/unauthadmin/edit`, {params: params}).then(res => res.data); };

export const unauthGetmylist = params => { return axios.get(`${base}/admin/unauthadmin/getmylist`, {params: params}).then(res => res.data); };
export const getunauthrequires = params => { return axios.get(`${base}/admin/requiresadmin/getunauthrequires`, {params: params}).then(res => res.data); };
/**
 * 监测需求审核接口
 */
export const requiresCheck = params => { return axios.get(`${base}/admin/requiresadmin/check`, {params: params}).then(res => res.data); };
export const requiresGetlist = params => { return axios.get(`${base}/admin/requiresadmin/getlist`, {params: params}).then(res => res.data); };
export const requiresRun = params => { return axios.get(`${base}/admin/requiresadmin/runrequire`, {params: params}).then(res => res.data); };
export const requiresGetinvoiceinfo = params => { return axios.get(`${base}/admin/requiresadmin/getinvoiceinfo`, {params: params}).then(res => res.data); };

/**
 * 监测订单管理接口
 */
export const requiresGetorderlist = params => { return axios.get(`${base}/admin/requiresadmin/getorderlist`, {params: params}).then(res => res.data); };
export const requiresEdit = params => { return axios.get(`${base}/admin/requiresadmin/edit`, {params: params}).then(res => res.data); };
export const requiresUploadreport = `${base}/admin/requiresadmin/uploadreport`; // 上传监测报告

/**
 * 后台汇款单接口
 */
export const receiptGetlist = params => { return axios.get(`${base}/admin/receiptadmin/getlist`, {params: params}).then(res => res.data); };

/**
 * 盗版下架接口
 */
export const downGetrequireslist = params => { return axios.get(`${base}/admin/downadmin/getrequireslist`, {params: params}).then(res => res.data); };
export const downGetundownlist = params => { return axios.get(`${base}/admin/downadmin/getundownlist`, {params: params}).then(res => res.data); };
export const downAdd = params => { return axios.get(`${base}/admin/downadmin/adddown`, {params: params}).then(res => res.data); };
export const downGetmyrequirelist = params => { return axios.get(`${base}/admin/downadmin/getmyrequirelist`, {params: params}).then(res => res.data); };
export const downGetmydownlist = params => { return axios.get(`${base}/admin/downadmin/getmydownlist`, {params: params}).then(res => res.data); };

/**
 * 上传接口()post接值)
 */
export const submitfile = `${base}/uploads/uploads/submitfile`; // 上传接口(post接值)
